package com.dl.study.config.jwt;

/**
 * @Author: user
 * @Date: 2021/10/25 10:26
 * @Description:
 */
public class UserContext implements AutoCloseable {
    static final ThreadLocal<LoginUser> current = new ThreadLocal<LoginUser>();

    public UserContext(LoginUser user) {
        current.set(user);
    }

    public static LoginUser getCurrentUser() {
        return current.get();
    }


    @Override
    public void close() throws Exception {
        current.remove();
    }
}
